home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 5.4 KB | 204 lines |
- package symantec.itools.awt;
-
- import java.awt.Event;
- import java.awt.LayoutManager;
- import java.awt.Panel;
-
- /**
- * This component provides the up/down or right/left buttons used in
- * spinners. It is used by abstract class Spinner and in the HorizontalSpinButton
- * and VerticalSpinButton components.
- *
- * @see symantec.itools.awt.Spinner
- * @see symantec.itools.awt.HorizontalSpinButton
- * @see symantec.itools.awt.VerticalSpinButton
- * @version 1.0, Nov 26, 1996
- * @author Symantec
- */
-
- public class SpinButtonPanel
- extends Panel
- {
- /**
- * The button used to increment the spinner value.
- */
- protected DirectionButton incButton;
- /**
- * The button used to decrement the spinner value.
- */
- protected DirectionButton decButton;
-
- /**
- * Constructs a spinner with up/down buttons.
- */
- public SpinButtonPanel()
- {
- add(incButton = new DirectionButton(DirectionButton.UP));
- add(decButton = new DirectionButton(DirectionButton.DOWN));
-
- //setDelay(250);
- //setNotifyWhilePressed(true);
- }
-
- /**
- * Sets whether the spinner buttons will continually send notify messages
- * while pressed.
- * @param f true = send messages; false = do not send messages
- * @see #getNotifyWhilePressed
- * @see #setDelay
- * @see #getDelay
- */
- public void setNotifyWhilePressed(boolean f)
- {
- incButton.setNotifyWhilePressed(f);
- decButton.setNotifyWhilePressed(f);
- }
-
- /**
- * Returns the current notifyWhilePressed status.
- * @see #setNotifyWhilePressed
- * @see #setDelay
- * @see #getDelay
- */
- public boolean getNotifyWhilePressed()
- {
- return incButton.getNotifyWhilePressed();
- }
-
- /**
- * Sets the notification message delay of the spinner buttons in milliseconds.
- * @param d the delay between notification messages in milliseconds
- * @see #setNotifyWhilePressed
- * @see #getDelay
- */
- public void setDelay(int d)
- {
- incButton.setNotifyDelay(d);
- decButton.setNotifyDelay(d);
- }
-
- /**
- * Returns the current delay between notification messages of the spinner
- * buttons in milliseconds
- * @see #setNotifyWhilePressed
- * @see #setDelay
- */
- public int getDelay()
- {
- return incButton.getNotifyDelay();
- }
-
- /**
- * Handles internal actions for this component.
- * This is a standard Java AWT method which usually gets called by the AWT
- * method handleEvent() in response to receiving an ACTION_EVENT event. In those
- * cases the o parameter contains the value in the event's arg field.
- *
- * @param e the event that caused this action
- * @param o the action
- * @return true if the action was handled
- * @see java.awt.Component#handleEvent
- */
- public boolean action(Event e, Object o)
- {
- if (e.target == incButton)
- {
- postEvent(new Event(this, Event.SCROLL_PAGE_UP, null));
-
- return true;
- }
- else if (e.target == decButton)
- {
- postEvent(new Event(this, Event.SCROLL_PAGE_DOWN, null));
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Enables this component so that it will respond to user input.
- * This is a standard Java AWT method which gets called to enable
- * this component. Once enabled this component will respond to user input.
- *
- * @see #disable
- */
- public synchronized void enable()
- {
- incButton.enable();
- decButton.enable();
- }
-
- /**
- * Disables this component so that it doesn't respond to user input.
- * This is a standard Java AWT method which gets called to disable
- * this component. Once disabled this component will not respond to user
- * input.
- *
- * @see #enable
- */
- public synchronized void disable()
- {
- incButton.disable();
- decButton.disable();
- }
-
- /**
- * This enables the incrementing button only.
- * @see #disableUpButton
- * @see #enableDownButton
- */
- public synchronized void enableUpButton()
- {
- incButton.enable();
- }
-
- /**
- * This enables the decrementing button only.
- * @see #disableDownButton
- * @see #enableUpButton
- */
- public synchronized void enableDownButton()
- {
- decButton.enable();
- }
-
- /**
- * This disables the incrementing button only.
- * @see #enableUpButton
- * @see #disableDownButton
- */
- public synchronized void disableUpButton()
- {
- incButton.disable();
- }
-
- /**
- * This disables the decrementing button only.
- * @see #enableDownButton
- * @see #disableUpButton
- */
- public synchronized void disableDownButton()
- {
- decButton.disable();
- }
-
- /**
- * Takes no action.
- * This is a standard Java AWT method which gets called to specify
- * which layout manager should be used to layout the components in
- * standard containers.
- *
- * Since layout managers CANNOT BE USED with this container the standard
- * setLayout has been OVERRIDDEN for this container and does nothing.
- *
- * @param l the layout manager to use to layout this container's components
- * (IGNORED)
- * @see java.awt.Container#getLayout
- **/
- public void setLayout(LayoutManager l)
- {
- }
- }
-